package cn.kgc.controller;

import cn.kgc.entity.SmbmsUser;
import cn.kgc.service.SmbmsUserService;
import cn.kgc.util.Pager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author example
 * @version 1.0
 */
@RestController
@RequestMapping("/smbmsUser")
@Api(tags = "用户管理接口")
@Validated
@Slf4j
@CrossOrigin
@SuppressWarnings("all")
public class SmbmsUserController {

    @Resource
    private SmbmsUserService smbmsUserService;

    @GetMapping("/detail/{userId}")
    @ApiOperation(value = "查询用户详情信息")
    @ApiImplicitParam(name ="userId",value = "用户id",dataType = "string",paramType = "path")
    public SmbmsUser detail(@PathVariable("userId") String userId){
        return smbmsUserService.getUserById(userId);
    }

    @GetMapping("/page")
    @ApiOperation(value="分页查询用户信息")
    @ApiImplicitParams({
       @ApiImplicitParam(name = "pageIndex",value = "当前页",defaultValue = "1",dataType="int",paramType = "query"),
       @ApiImplicitParam(name = "pageSize",value = "每页显示条数",defaultValue = "10",dataType="int",paramType = "query"),
       @ApiImplicitParam(name = "userName",value = "用户名",dataType="string",paramType = "query")
     })
    public Pager<SmbmsUser> page(
            @RequestParam(defaultValue = "1") int pageIndex,
            @RequestParam(defaultValue = "10") int pageSize,
            @RequestParam(defaultValue = "") String userName
    ){
        return smbmsUserService.pageList(pageIndex,pageSize,userName);
    }
}
